package chapter1;

public class ImprovedFibonacci {
	
	static final int MAX = 50;//class level

	/**
	 * Print out the Fibonacci sequence for values < MAX
	 * marking evens with a '*'
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		//ONLY 2 local variables
		int lo = 1;
		int hi = 1;
		String mark;
		
		System.out.println("1: " + lo);
		for(int i = 2; hi <= MAX; i++){
			if(hi % 2 == 0){
				mark = " *";
			}else{
				mark = "";
			}
			System.out.println(i + ": " + hi + mark);
			hi = lo + hi; //new hi
			lo = hi - lo; //new lo that is the old hi
		}
	}

}
